package stdio.costa.imoca.model;

import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

@Entity
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@NamedQueries({
		@NamedQuery(name = "findUserByName", query = "from MocaUser mu where mu.name =:name"),
		@NamedQuery(name = "findUserByEmail", query = "from MocaUser mu where mu.email =:email"),
		@NamedQuery(name = "findUserByPhone", query = "from MocaUser mu where mu.phone =:phone"),
		@NamedQuery(name = "findUserByQQUid", query = "from MocaUser mu where mu.qqUid =:qqUid"),
		@NamedQuery(name = "findUserByWeiboUid", query = "from MocaUser mu where mu.weiboUid =:weiboUid"),
		@NamedQuery(name = "findUserByWeiboUidAndAccessToken", query = "from MocaUser mu where mu.weiboUid =:weiboUid and mu.weiboAccessToken=:weiboAccessToken"),
		@NamedQuery(name = "findUserByUuidAndPassword", query = "from MocaUser mu where mu.uuid =:uuid and mu.password=:password"),
		@NamedQuery(name = "findUserByQQUidAndAccessToken", query = "from MocaUser mu where mu.qqUid =:qqUid and mu.qqAccessToken=:qqAccessToken"),
		@NamedQuery(name = "findUserByNameOrEmailOrPhone", query = "from MocaUser mu where mu.name =:name or mu.email=:email or phone=:phone") })
public class MocaUser extends UuidEntity implements Serializable {

	private static final long serialVersionUID = -113726144746222597L;

	private String name;

	@XmlTransient
	private String password;

	private String email;

	private String phone;

	@OneToOne(cascade = CascadeType.ALL)
	private Address address = new Address();

	@Column(name = "weibo_uid")
	private String weiboUid;

	@Column(name = "weibo_access_token")
	@XmlTransient
	private String weiboAccessToken;

	@Column(name = "weibo_login")
	private Boolean weiboLogin;

	@Column(name = "qq_uid")
	private String qqUid;

	@XmlTransient
	@Column(name = "qq_access_token")
	private String qqAccessToken;

	@Column(name = "qq_login")
	private Boolean qqLogin;

	public MocaUser() {
	}

	public MocaUser(String name, String password, Address address) {
		this.name = name;
		this.password = password;
		this.address = address;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Address getAddress() {
		return address;
	}

	public void setAddress(Address address) {
		this.address = address;
	}

	public String getWeiboUid() {
		return weiboUid;
	}

	public void setWeiboUid(String weiboUid) {
		this.weiboUid = weiboUid;
	}

	public String getWeiboAccessToken() {
		return weiboAccessToken;
	}

	public void setWeiboAccessToken(String weiboAccessToken) {
		this.weiboAccessToken = weiboAccessToken;
	}

	public String getQqUid() {
		return this.qqUid;
	}

	public void setQqUid(String qqUid) {
		this.qqUid = qqUid;
	}

	public String getQqAccessToken() {
		return qqAccessToken;
	}

	public void setQqAccessToken(String qqAccessToken) {
		this.qqAccessToken = qqAccessToken;
	}

	public String getEmail() {
		return email;
	}

	public Boolean getWeiboLogin() {
		return weiboLogin;
	}

	public void setWeiboLogin(Boolean weiboLogin) {
		this.weiboLogin = weiboLogin;
	}

	public Boolean getQqLogin() {
		return qqLogin;
	}

	public void setQqLogin(Boolean qqLogin) {
		this.qqLogin = qqLogin;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}
}
